import requests
from common.token01 import login
class BuMen:
    def add(self,headers,req_body):
        resp = requests.post(url="http://ihrm2-test.itheima.net/api/company/department",
                             headers=headers,
                             json=req_body)
        return resp
    def query (self,id,headers):
        resp = requests.get(url="http://ihrm2-test.itheima.net/api/company/department/"+id,
                            headers=headers)
        return resp
    def put(self,id,headers,req_body):
        resp = requests.put(url="http://ihrm2-test.itheima.net/api/company/department/"+id,
                             headers=headers,
                             json=req_body)
        return resp
    def delete0(self,id,headers,):
        resp = requests.delete(url="http://ihrm2-test.itheima.net/api/company/department/"+id,
                             headers=headers )
        return resp


if __name__ == "__main__":
    a = BuMen()
    resp = a.add(login(),{"name":"拉拉","code":"1256"})
    print(resp.json())
    resp2 = a.query(login())
    print(resp2.json())
    resp3 = a.delete0(login())
    print(resp3.json())